package ar.com.altaagenda.spiders;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;

import ar.com.altaagenda.Result;

public abstract class SheSpider {

	protected static final String NOT_FOUND = "NOT_FOUND";
	protected static final String NOT_AVAILABLE = "N/A";
	protected Calendar startDate;
	protected Calendar endDate;
	protected SimpleDateFormat dateFormater = new SimpleDateFormat("dd/MM/yyyy");

	public SheSpider(){
		//Gathers results only for today
		this(Calendar.getInstance(), Calendar.getInstance());
	}
	
	public SheSpider(Calendar startDate, Calendar endDate){
		this.startDate = startDate;
		this.endDate = endDate;
	}

	protected String removeTagsAndEnters(String html){
		
		html = html.replaceAll("\\<(.|\\n)*?\\>", "").replaceAll("\\n", "").trim();
		return html;
	}
	
	protected String removeSpecificTags(String html, String tagName){
		
		html = html.replaceAll("<\\s*\\/?\\s*"+tagName+"\\s*.*?>", "").trim();
		return html;
	}
	
	protected int decodeMes(String mes){
		switch (mes.toLowerCase()) {
			case "enero": return 1;
			case "febrero":	return 2;
			case "marzo": return 3;
			case "abril": return 4;
			case "mayo": return 5;
			case "junio": return 6;
			case "julio": return 7;
			case "agosto": return 8;
			case "septiembre": return 9;
			case "setiembre": return 9;
			case "octubre":	return 10;
			case "noviembre": return 11;
			case "diciembre": return 12;
	
			default:return 0;
		}
	}

	public abstract List<Result> getResults();
	protected abstract String getSiteName();
}
